home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 11481 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.5 KB

  1. Path: mail2news.demon.co.uk!genesis.demon.co.uk
  2. From: Lawrence Kirby <fred@genesis.demon.co.uk>
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Why does the "universal bugfunction" gets() survive in 1996?
  5. Date: Sun, 24 Mar 96 14:32:11 GMT
  6. Organization: none
  7. Message-ID: <827677931snz@genesis.demon.co.uk>
  8. References: <DoDGq8.Dqq@scn.org> <4irokq$j1b@ferrari.NetXpress.com>
  9. Reply-To: fred@genesis.demon.co.uk
  10. X-NNTP-Posting-Host: genesis.demon.co.uk
  11. X-Newsreader: Demon Internet Simple News v1.27
  12. X-Mail2News-Path: genesis.demon.co.uk
  13.  
  14. In article <4irokq$j1b@ferrari.NetXpress.com>
  15.            ghporter@NetXpress.com "Glenn H. Porter" writes:
  16.  
  17. >Kurt,
  18. >
  19. >No function is inherently dangerous.  The danger lies in expecting the
  20. >compiler/language to keep you from doing something dangerous.  My
  21. >first C teacher told each of his classes "If you don't see the BIOS
  22. >copyright message as your program output, you're not trying.  Just
  23. >make sure you don't see it twice for the same bug."
  24. >
  25. >If you use a function that dosn't check the length of the buffer, then
  26. >you have to check the buffer.  It's that simple.  If you don't like
  27. >it, don't use it.
  28.  
  29. The problem is that gets() doesn't give you the opportunity to check the
  30. length of the buffer - whether it will write beyond it or not is entirely
  31. beyond the control of the rest of the program. gets() is inherently
  32. dangerous.
  33.  
  34. -- 
  35. -----------------------------------------
  36. Lawrence Kirby | fred@genesis.demon.co.uk
  37. Wilts, England | 70734.126@compuserve.com
  38. -----------------------------------------
  39.